package com.localjoycommunity.cpdj.project.system.service.impl;

import com.localjoycommunity.cpdj.common.utils.DateUtils;
import com.localjoycommunity.cpdj.project.system.domain.SysOption;
import com.localjoycommunity.cpdj.project.system.mapper.SysOptionMapper;
import com.localjoycommunity.cpdj.project.system.service.ISysOptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 试题选项Service业务层处理
 *
 * @author leepandar
 * @date 2020-11-01
 */
@Service
public class SysOptionServiceImpl implements ISysOptionService {
    @Autowired
    private SysOptionMapper sysOptionMapper;

    /**
     * 查询试题选项
     *
     * @param optionId 试题选项ID
     * @return 试题选项
     */
    @Override
    public SysOption selectSysOptionById(Long optionId) {
        return sysOptionMapper.selectSysOptionById(optionId);
    }

    /**
     * 查询试题选项列表
     *
     * @param sysOption 试题选项
     * @return 试题选项
     */
    @Override
    public List<SysOption> selectSysOptionList(SysOption sysOption) {
        return sysOptionMapper.selectSysOptionList(sysOption);
    }

    @Override
    public List<SysOption> selectSysOptionListByQuestionId(long questionId) {
        return sysOptionMapper.selectSysOptionListByQuestionId(questionId);
    }

    /**
     * 新增试题选项
     *
     * @param sysOption 试题选项
     * @return 结果
     */
    @Override
    public int insertSysOption(SysOption sysOption) {
        sysOption.setCreateTime(DateUtils.getNowDate());
        return sysOptionMapper.insertSysOption(sysOption);
    }

    /**
     * 修改试题选项
     *
     * @param sysOption 试题选项
     * @return 结果
     */
    @Override
    public int updateSysOption(SysOption sysOption) {
        sysOption.setUpdateTime(DateUtils.getNowDate());
        return sysOptionMapper.updateSysOption(sysOption);
    }

    /**
     * 批量删除试题选项
     *
     * @param optionIds 需要删除的试题选项ID
     * @return 结果
     */
    @Override
    public int deleteSysOptionByIds(Long[] optionIds) {
        return sysOptionMapper.deleteSysOptionByIds(optionIds);
    }

    /**
     * 删除试题选项信息
     *
     * @param optionId 试题选项ID
     * @return 结果
     */
    @Override
    public int deleteSysOptionById(Long optionId) {
        return sysOptionMapper.deleteSysOptionById(optionId);
    }
}
